﻿//*** Guidance generated code ***//
using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Web.UI;

using ProjectBase.Core;

namespace $safeprojectname$
{
    /// <summary>html &lt;FIELDSET&gt; element</summary>
    public class Fieldset : ContentControl<ICoreModel, IVisualControl, Fieldset>
    {
        #region members
        Div _div = new Div();
        Legend _legend = new Legend();
        #endregion members

        #region constructor
        public Fieldset(string cssClassName = null, string legend = null, bool doLocalize = true)
            : base(cssClassName)
        {
            base.Add(_legend);
            base.Add(_div);
            _legend.SetText(legend, doLocalize);
        }
        #endregion constructor

        #region Add -> to DIV
        public override void Add(IVisualControl control)
        {
            Div.Add(control);
        }
        #endregion Add -> to DIV

        #region Render
        protected override void RenderChild(HtmlTextWriter writer, IVisualControl control)
        {
            if (control.Equals(Legend)
                && !Legend.HasText)
            {
                return;
            }
            base.RenderChild(writer, control);
        }
        #endregion Render

        #region Set
        public virtual Fieldset SetLegend(string text, bool doLocalize = true)
        {
            Legend.SetText(text, doLocalize);
            return this;
        }
        #endregion Set

        #region properties
        protected override string TagName
        {
            get { return Tag.Fieldset; }
        }

        protected virtual Legend Legend
        {
            get { return _legend; }
            set { _legend = value; }
        }

        protected virtual Div Div
        {
            get { return _div; }
            set { _div = value; }
        }
        #endregion properties
    }
}